package NG::Gen::App;
use strict;
use warnings;
use utf8;

use NG::Sys::Cfg;

use base 'NG::Sys::App';

sub users {
	my $self = shift;
	my $dbh = shift;

	unless($self->{_users}){
		require NG::Gen::Users;
		$self->{_users} = NG::Gen::Users->new(app => $self, dbh => $dbh || $self->dbh);
	}
	return $self->{_users};
}
sub chat_message {
	my $self = shift;
	unless($self->{_chat_message}){
		require NG::Chat::Client::Admin;
		$self->{_chat_message} = NG::Chat::Client::Admin->new($self);
	}
	return $self->{_chat_message};
}
sub chat_query {
	my $self = shift;
	unless($self->{_chat_query}){
		require NG::Chat::Client::Query;
		$self->{_chat_query} = NG::Chat::Client::Query->new($self);
	}
	return $self->{_chat_query};
}
sub search {
	my $self = shift;
	unless($self->{_search}){
		require NG::Gen::Action::Search;
		my $cfg = config("search");
		$self->{_search} = NG::Gen::Action::Search->new(
						app => $self,
						dbh => $self->dbh,
						%$cfg,
					);
	}
	return $self->{_search};
}
1;
